#include "../include/ehome.h"
#include <fcntl.h>
#include <linux/input.h>
#include <stdio.h>
#include "beep.h"
void *hcsr_thread(void *arg){
    struct input_event key;
    /*阻塞方式*/
    int btn_fd=open("/dev/input/event5",O_RDONLY);
    if(btn_fd<0){
        perror("open key failed");
        return NULL;
    }
    while(1){
        read(btn_fd,&key,sizeof(key));
        if(key.type==EV_KEY&&key.value==1){
            beep(BEEP_ON);
        }else if(key.type==EV_KEY&&key.value==0){
            beep(BEEP_OFF);
        }
    }
    close(btn_fd);
    return NULL;
}
/*
void *FF_thread(void *arg){
     int fd=(int *)arg;
    char if_FF;
    /*阻塞方式*/
    while(1){
        read(fd,&if_FF,sizeof(if_FF));
	if(if_FF>0){
		system("poweroff");
	}
    }
    close(fd);
    return NULL;
}*/